home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Almathera Ten Pack 3: CDPD 3
/
Almathera Ten on Ten - Disc 3: CDPD3.iso
/
fish
/
726-750
/
737
/
ansi
/
ansi.doc
< prev
next >
Wrap
Text File
|
1995-03-18
|
4KB
|
116 lines
ANSI V1.6
=========
Dr. Andrew C. R. Martin
SciTech Software
This program is not in the public domain, but it may be freely copied
and distributed for no charge providing this header is included.
The code may be modified as required, but any modifications must be
documented so that the person responsible can be identified. If someone
else breaks this code, I don't want to be blamed for code that does not
work! The code may not be sold commercially without prior permission from
the author, although it may be given away free with commercial products,
providing it is made clear that this program is free and that the source
code is provided with the program.
****************************************************************************
Description
===========
This program alters function definitions to convert non-ANSI C code to
ANSI form. The -k and -p flags allow conversion from ANSI to K&R and
generation of prototypes respectively.
There are four minor problems:
1. In generation of prototypes. If a function has been defined with no
explicit type it defaults to being int. Strictly the prototype should
explicitly state this is int, but doesn't.
2. If a conversion actually occurs (either to or from ANSI) any comments
which were in the definition will be lost.
3. If a function is defined as taking no parameters, for example:
void func()
{
...
}
the prototype ouput by ansi is
void func();
instead of
void func(void);
4. It won't cope with ANSI variable list arguments i.e.
void func(char *fmt, ...)
{
...
}
Sometime, I hope to get around to fixing at least some of these!
The only restriction (that I can think of!) on the code being processed
is that a function definition must be the first thing on a line.
i.e. if a comment is placed on the same line as the definition but before
it, the program will think the whole line is a comment.
My thanks to B. de Batz who pointed out some of these problems and a
few special case bugs in the earlier versions and to Bob Bruccoleri
who found another small bug.
****************************************************************************
Usage:
======
The program may only be used from the CLI:
ansi [-k -p] <in.c> <out.c>
-k generates K&R form code from ANSI
-p generates a set of prototypes
****************************************************************************
Revision History:
=================
V1.0 17.12.91
Added support for prototype and K&R code generation. Also reorganised
some code.
V1.1 21.01.92
A little tidying for VAX and slightly more useful error messages when
making ANSI and failing to find parameter definition---this spots bugs!
V1.2 14.02.92
Fixed a bug whereby variable names which were subsets of the associated
type were not being found correctly.
e.g. func(o,w) struct obs *o; struct wor *w; { }
did not inherit *'s correctly in the ANSI version.
Introduced FindVarName() for this purpose.
Also added version string.
V1.3 19.02.92
Fixed a reported bug where comments weren't handled properly in
definitions of multiple parameters of a single type. e.g. the following
failed:
func(p1,p2)
char *p1, /* Comment 1 */
*p2 /* Comment 2 */
{
}
Introduced KillComments() for this purpose.
V1.4 18.03.92
Fixed bug reported by Bob Bruccoleri in process_file(). If a comment
on the line of an external variable definition contained a (, the code
would think this was a prototype definition and get very confused.
Now kills the comments before testing for the presence of a (.
Improved function definition comments.
V1.5 26.03.92
Fixed same bug as in V1.2, but for ANSI-->K&R; variable names, if a
subset of a type name were getting picked up incorrectly.
V1.6 01.04.92
Small change to comments to work with my autodoc program.